﻿function Collection() {
    this.list = [];
};

Collection.prototype.get = function () {
    return this.list;
}

Collection.prototype.set = function (list) {
    this.list = list;
}

Collection.prototype.add = function (item) {
    this.list.push(item);
}

Collection.prototype.remove = function (id) {
    this.list = _.reject(this.list, function (x) {
        return x.id === id;
    });
}

Collection.prototype.edit = function (item) {
    var index = _.findIndex(this.list, { id: item.id });
    this.list.splice(index, 1, item);
}